package apis

import (
	"gitee.com/byx_darwin/ncloud-go/core"
	"gitee.com/byx_darwin/ncloud-go/core/net/consts"
)

type QueryFlowConditions struct {
	StartTime                int64    `json:"start_time"`
	EndTime                  int64    `json:"end_time"`
	Interval                 int64    `json:"interval"`
	DomainList               []string `json:"domain_list"`
	IspList                  []string `json:"isp_list"`
	RegionList               []string `json:"region_list"`
	NetLayerProtocol         string   `json:"net_layer_protocol"`
	ApplicationLayerProtocol string   `json:"application_layer_protocol"`
}
type QueryFlowRequest struct {
	core.NCloudRequest
	QueryFlowConditions
}

func NewQueryFlowRequest(startTime, endTime, interval int64) *QueryFlowRequest {
	return &QueryFlowRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/flow",
			Method: consts.MethodPost,
		},
		QueryFlowConditions: QueryFlowConditions{
			StartTime: startTime,
			EndTime:   endTime,
			Interval:  interval,
		},
	}
}
func NewQueryFlowRequestWithDomains(startTime, endTime, interval int64, list []string) *QueryFlowRequest {
	return &QueryFlowRequest{
		NCloudRequest: core.NCloudRequest{
			Path:   "/flow",
			Method: consts.MethodPost,
		},
		QueryFlowConditions: QueryFlowConditions{
			StartTime:  startTime,
			EndTime:    endTime,
			Interval:   interval,
			DomainList: list,
		},
	}
}

func (q *QueryFlowRequest) SetNetworkLayerProtocol(protocol string) {
	q.NetLayerProtocol = protocol
}

func (q *QueryFlowRequest) SetApplicationLayerProtocol(protocol string) {
	q.ApplicationLayerProtocol = protocol
}
func (q *QueryFlowRequest) SetIspList(list []string) {
	q.IspList = list
}
func (q *QueryFlowRequest) SetRegionList(list []string) {
	q.RegionList = list
}

type QueryFlowResponse struct {
	Ok      bool     `json:"ok"`
	Msg     string   `json:"msg"`
	TrackID string   `json:"track_id"`
	Data    FLowData `json:"data"`
}

type FLowData struct {
	Interval int64        `json:"interval"`
	FlowList []FlowObject `json:"flow_list,omitempty"`
}

type FlowObject struct {
	Time                     uint64 `json:"time"`
	Domain                   string `json:"domain"`
	Flow                     uint64 `json:"flow"`
	Region                   string `json:"region"`
	Isp                      string `json:"isp"`
	NetLayerProtocol         string `json:"net_layer_protocol"`
	ApplicationLayerProtocol string `json:"application_layer_protocol"`
}
